export default {
  data() {
    return {
      MX_modal: false, // modal窗口开关
      MX_tableLoading: false, // table刷新
      MX_DataList: [], // 数据list
      MX_searchParams: {}, // 筛选数据
      MX_constParams: {}, // 固定筛选数据
      MX_pageNo: 1, // 页码
      MX_pageSize: 20, // 查询条数
      MX_total: 0, // 总数
      MX_apis: {} // 接口地址
    };
  },
  watch: {},
  methods: {
    // 获取list数据
    MX_getData() {
      console.log("listmixins");
      if (this.MX_tableLoading) return;
      if (!this.MX_apis.getlist) return;
      this.MX_tableLoading = true;
      let page = {
        pageSize: this.MX_pageSize, // 起始页
        pageNo: this.MX_pageNo // 查询数量
      };
      let params = Object.assign(page, this.MX_searchParams, this.MX_constParams);
      this.httpGet(this.API[this.MX_apis.getlist], params)
        .then((res) => {
          this.MX_DataList = res.data.rows;
          this.MX_total = res.data.totalRows;
          this.MX_tableLoading = false;
        })
        .catch((err) => {
          this.MX_tableLoading = false;
        });
    },
    // 切换页码
    MX_changePageFun(page) {
      this.MX_pageNo = page;
      this.MX_getData();
    },
    // 分页重置
    MX_resetPage() {
      this.MX_pageNo = 1;
      this.MX_getData();
    },
    // 字典
    MX_getStatusList(type) {
      this.httpGet(this.API[this.MX_apis.dictionariesAPI],{
        pageSize: 999,
        dictTypeCode: type
      })
        .then((res) => {
          let statusList = {};
          let list = res.data.rows;
          list.forEach((item) => {
            statusList[item.dictCode] = {
              status: item.dictName,
              color: item.dictShortName
            };
          });
          this[type] = statusList;
        })
        .catch((err) => {
          console.log(err);
        });
    }
  }
};
